<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 360px"
      :row-class-name="tableRowClassName"
    >
      <el-table-column prop="id" label="序号" width="180" align="center">
      </el-table-column>
      <el-table-column
        prop="name"
        label="服务项目名称"
        width="180"
        align="center"
      >
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        {
          id: 1,
          name: "家庭保洁",
        },
        {
          id: 2,
          name: "家电清洗",
        },
        {
          id: 3,
          name: "深度保洁",
        },
        {
          id: 4,
          name: "放心搬家",
        },
        {
          id: 5,
          name: "做饭阿姨",
        },
        {
          id: 6,
          name: "钟点工",
        },
        {
          id: 7,
          name: "清洁保养",
        },
        {
          id: 8,
          name: "家电维修",
        },
        {
          id: 9,
          name: "洗衣洗鞋",
        },
      ],
    };
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 3 === 1) {
        return "warning-row";
      } else if (rowIndex % 3 === 2) {
        return "success-row";
      }
      return "";
    },
  },
};
</script>

<style lang="less">
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>
